﻿using DWH.PP.Recursive.MMA;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using DWH.PP;
using System.Collections.Generic;
using DWH.Utils;

namespace RDTest
{
    
    
    /// <summary>
    ///This is a test class for MMASelfPicsPullTaskTest and is intended
    ///to contain all MMASelfPicsPullTaskTest Unit Tests
    ///</summary>
    [TestClass()]
    public class MMASelfPicsPullTaskTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for ProcessTargetHtmlContent
        ///</summary>
        [TestMethod()]
        [DeploymentItem("DWH.dll")]
        public void ProcessTargetHtmlContentTest()
        {
            MMAPicturesBoardPullTask_Accessor target = new MMAPicturesBoardPullTask_Accessor();

            //string pageUrl = "http://174.123.15.31/forumdisplay.php?fid=59";

            target.Enable = true;
            Guid newId = Guid.NewGuid();
            target.TaskName = "UT for PPBoardPullTask" + newId.ToString();

            target.ExtendData = new Dictionary<string, string>();
            target.ExtendData[DWHConstants.KEY_BOARD_START_URL] = "http://174.123.15.31/forumdisplay.php?fid=59";
            target.ExtendData[DWHConstants.KEY_CONTENT_PAGE_URL_PATTERN] = @"viewthread.php\?tid=[\d+]";//viewthread.php?tid=791269&amp;extra=page%3D1
            target.ExtendData[DWHConstants.KEY_NEXT_PAGE_URL_PATTERN] = @"forumdisplay.php\?fid=59";//forumdisplay.php?fid=59&amp;page=2
            target.ExtendData[DWHConstants.KEY_PAGE_ENCODING] = "gbk";//gbk
            target.ExtendData[DWHConstants.KEY_CONTENT_TARGET_ELEMENT] = "//div[@id]";//<div id="message12194466" class="t_msgfont">
            target.ExtendData[DWHConstants.KEY_CONTENT_TARGET_ELEMENT_ATTRIBUTE_NAME] = "id";
            target.ExtendData[DWHConstants.KEY_CONTENT_TARGET_ELEMENT_ATTRIBUTE_VALUE] = @"message[\d+]";

            target.Initialize();
            target.Run();
            //target.processPageList(pageUrl);
        }
    }
}
